<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <script src="../../js/jquery3.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <meta charset="UTF-8">
    <title>查看日志</title>
</head>
<style>
    html, body {
        height: 100%;
    }

    .hideLong {
        width: 300px;
        white-space: nowrap;
        overflow: hidden;
        float: left;
        text-indent: 4em;
        -o-text-overflow: ellipsis; /* for Opera */
        text-overflow: ellipsis; /* for IE */
    }

    #all {
        background-color: white;
        width: 96%;
        height: 100%;

        margin: 20px 20px auto;
    }
</style>

<body bgcolor="whitesmoke">

<div id="all">
    </br>
    &nbsp;&nbsp;&nbsp;&nbsp;<i class="layui-icon layui-icon-note" style="width: 150px;height: 100px;"><b>&nbsp;查看日志</b></i>
    </br>
    </br>

    </br>
    <div class="layui-collapse" lay-accordion>

        <div class="layui-colla-item">
            <h2 class="layui-colla-title">
                <div class="layui-timeline-content layui-text">
                    <h3 class="layui-timeline-title" style="margin-top: 5px"> 一天内</h3>
                </div>
            </h2>
            <div class="layui-colla-content layui-show" id="oneDay">

            </div>
        </div>

        <div class="layui-colla-item">
            <h2 class="layui-colla-title">
                <div class="layui-timeline-content layui-text">
                    <h3 class="layui-timeline-title" style="margin-top: 5px"> 三天内</h3>
                </div>
            </h2>
            <div class="layui-colla-content " id="threeDay">
            </div>
        </div>

        <div class="layui-colla-item">
            <h2 class="layui-colla-title">
                <div class="layui-timeline-content layui-text">
                    <h3 class="layui-timeline-title" style="margin-top: 5px"> 一周内</h3>
                </div>
            </h2>
            <div class="layui-colla-content " id="oneWeek">
            </div>
        </div>


        <div class="layui-colla-item">
            <h2 class="layui-colla-title">
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title" style="margin-top: 5px"> 过去的日志</div>
                </div>
            </h2>
            <div class="layui-colla-content " id="weekAfter">
            </div>
        </div>


    </div>

</div>
</body>
<script>
    $.post("/user/getSelf", {}, function (data) {
        if (data != null) {

            //一天内
            $.post("/log/findDayLog", {u_id: data.u_id}, function (res) {
                var htm = ""
                if (res.length!=0){
                    for (var i = 0; i < res.length; i++) {
                        //如果日期在一周内循环输出展示
                        htm += `
            <p class="hideLong">
                ` + res[i].l_title + `
            </p>
            <div><a href="detail.html?u_id=` + res[i].u_id + `&l_id=` + res[i].l_id + `&u_name=` + data.u_name + `">&nbsp;&nbsp; <i class="layui-icon">&#xe621;</i>详情</a></div>
            <br>
        </div>

                `
                    }

                }else {
                    htm += `<center>无日志</center>`
                }

                $("#oneDay").html(htm);
            })

            //三天内
            $.post("/log/findThreeLog", {u_id: data.u_id}, function (res) {
                var htm = ""
                if (res.length!=0){

                    for (var i = 0; i < res.length; i++) {
            //如果日期在一周内循环输出展示
                    htm += `
            <p class="hideLong">
                ` + res[i].l_title + `
            </p>
            <div><a href="detail.html?u_id=` + res[i].u_id + `&l_id=` + res[i].l_id + `&u_name=` + data.u_name + `">&nbsp;&nbsp; <i class="layui-icon">&#xe621;</i>详情</a></div>
            <br>
        </div>

                `
                }


            }else {
                htm += `<center>无日志</center>`
            }
                $("#threeDay").html(htm);
            })

            //一周内
            $.post("/log/findWeekLog", {u_id: data.u_id}, function (res) {
                var htm = ""
                if (res.length!=0){

                    for (var i = 0; i < res.length; i++) {
        //如果日期在一周内循环输出展示
                    htm += `
            <p class="hideLong">
                ` + res[i].l_title + `
            </p>
            <div><a href="detail.html?u_id=` + res[i].u_id + `&l_id=` + res[i].l_id + `&u_name=` + data.u_name + `">&nbsp;&nbsp; <i class="layui-icon">&#xe621;</i>详情</a></div>
            <br>
        </div>

                `
                }
                }else {
                    htm += `<center>无日志</center>`
                }
                $("#oneWeek").html(htm);
            })

            //过去
            $.post("/log/findBeforeLog", {u_id: data.u_id}, function (res) {
                var htm2 = ""
                if (res.length!=0){

                    for (var i = 0; i < res.length; i++) {
            //如果日期在一周内循环输出展示
                    htm2 += `
                <p class="hideLong">
                    ` + res[i].l_title + `
                </p>
                <div><a href="detail.html?u_id=` + res[i].u_id + `&l_id=` + res[i].l_id + `&u_name=` + data.u_name + `">&nbsp;&nbsp; <i class="layui-icon">&#xe621;</i>详情</a></div>
                <br>
                    `
                }
                }else {
                    htm += `<center>无日志</center>`
                }
                $("#weekAfter").html(htm2);
            })


        } else {
            alert("未登录，请先登录")
            location.href = "../login/login.html"
        }
    })
</script>
<script>
    //注意：折叠面板 依赖 element 模块，否则无法进行功能性操作

    layui.use('element', function () {
        var element = layui.element;

        //…

    });
</script>
</html>